<?php

namespace App\Models;

use App\Services\Product\ExcelService;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

class B2cList extends Model{
    
    //b2c列表
    protected $table = 'b2c_lists';

    public $timestamps = false;

    protected $fillable = [
        //库存分配状态
        'inventory_allocation_status1',
        //线下处理状态
        'offline_processing_status',
        //提示    
        'hint',
        //是否冻结  
        'is_freeze',
        //单据类型  
        'invoices_type',
        //订单编号  
        'order_num',
        //订单日期  
        'order_date',
        //会员名称  
        'member_name',
        //来源网店  
        'source_online_shop',
        //来源订单号 
        'source_order_num',
        //单据状态  
        'invoices_status',
        //交易状态  
        'deal_status',
        //关闭状态  
        'closure_status',
        //买家留言  
        'buyer_leave_word',
        //卖家备注  
        'seller_remark',
        //备注    
        'remark',
        //虚拟订单  
        'virtual_order',
        //是否开票  
        'is_invoice',
        //价税合计  
        'price_tax_summation',
        //运费    
        'freight',
        //应支付金额 
        'due_money',
        //已到帐金额 
        'collected_balances',
        //付款时间  
        'paid_at',
        //库存分配状态
        'inventory_allocation_status2',
        //套件数量  
        'combo_quantity',
        //物料条码  
        'material_code',
        //物料编码  
        'material_num',
        //物料名称  
        'material_name',
        //规格型号  
        'specifications',
        //单位    
        'unit',
        //数量    
        'quantity',
        //赠品    
        'gift',
        //含税单价 
        'unit_price',
        //折扣率   
        'discount_rate',
        //折扣额   
        'deduction',
        //净价    
        'net_price',
        //套件编码  
        'combo_code',
        //套件名称  
        'combo_name',
    ];

    public function setOrderDateAttribute($value){
        $value = (new ExcelService)->setColumnValueToDateString($value);
        $this->attributes['order_date'] = $value;
    }

    public function setPaidAtAttribute($value){
        $value = (new ExcelService)->setColumnValueToDateString($value);
        $this->attributes['paid_at'] = $value;
    }

}
